<?php
/**
 * Created by PhpStorm.
 * User: ybjaa
 * Date: 2017/6/23
 * Time: 10:42
 */

namespace App\Business\Users;


use App\Business\BusBase;
use App\Business\ReturnResult;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

/**
 * 根据原始密码重置密码
 * @package App\Business\Users
 */
class ResetPassword_SoucePassword extends BusBase
{
    protected $_isCheck=false;

    public $sourcePassword;
    public $newPassword;




    protected function Handle()
    {

        //获得用户
        $user=Auth::user();

        if (!Hash::check($this->sourcePassword, $user->getAuthPassword())) {
            return ReturnResult::Error(null,"密码错误");
            // 密码对比...
        }



        $user->password=Hash::make($this->newPassword);
        $user->save();

        return ReturnResult::Success();

    }


    protected function PermissionCheck()
    {
        return $this->Check();
    }



    public function GetBusinessName()
    {
        return "根据原始密码重置新密码";
    }


}